#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, e = 0;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = n - 1; i >= 0; i--)
		e = ceil((e + h[i]) / 2.0);
	cout << e << endl;
	return 0;
}

// 作者：nbgao
// 链接：https://www.nowcoder.com/exam/test/86764418/submission?pid=16516564
// 来源：牛客网